/**
 *	管理人员
 *
 *	@auth liangpingzheng
 *	@date 2018-07-18
 */
layui.use(['func','laydate'],function(){
    var laydate = layui.laydate,
        func = layui.func,
        form = layui.form,
        $ = layui.$;

    if(A=='index') {

        //【TABLE列数组】
        var cols = [
            { type:'checkbox', fixed: 'left' }
            ,{ field:'id', width:"6%", title: '工号', align:'center' ,templet:function (d) {
                    return d.brokerid;
                }}
            ,{ field:'bname', width:"6%", title: '真实姓名', align:'center', }
            ,{ field:'enterYear', width:"6%", title: '从来年限', align:'center', }
            ,{ field:'brokerPoints', width:"6%", title: '积分', align:'center', }


            ,{ field:'mobile', width:"9%", title: '手机', align:'center' }
            ,{ field:'areaname', width:"8%", title: '大区', align:'center' }
            ,{ field:'groupname', width:"8%", title: '组团', align:'center' }
            ,{ field:'teamname', width:"10%", title: '逻辑门店', align:'center', }
            ,{ field:'shopname', width:"8%", title: '门店', align:'center', }
            // ,{ field:'enterDtStr', width:100, title: '入职日期', align:'center', }
            ,{ field:'netBroker', width:"7%", title: '网络经纪人', align:'center', templet:"#statusTpl" }
            ,{ field:'userStatus', width:"5%", title: '状态', align:'center', templet:function(d){
                    var str = "";
                    if(d.userStatus==1){
                        str = '<span class="layui-btn layui-btn-cyan layui-btn-xs">离职</span>';
                    }else if(d.userStatus==2){
                        str = '<span class="layui-btn layui-bg-green layui-btn-xs">在职</span>';
                    }
                    return str;
                }}
            ,{  width:"10%", title: '功能操作', align:'center', toolbar: '#toolBar' }
        ];

        //【TABLE渲染】
        func.tableIns(cols,"tableList",function(layEvent,data,field){
            if(layEvent === 'auth'){
                layer.msg('权限设置');

                //独立权限设置
                location.href = mUrl + "/adminAuth/index/?type=2&type_id="+data.id;

            }else if(layEvent === 'role'){
                layer.msg("角色设置");

                //设置角色
                var url = cUrl + "/setRole/?admin_id="+data.id;
                func.showWin("角色配置",url,600,350);

            }else if(layEvent === 'reset'){
                layer.msg('初始化密码操作');

                //初始化密码
                var url = cUrl + "/resetPwd/?id="+data.id;
                func.showWin("重置密码",url,450,250);

            }
            // else if(layEvent==='del2'){
            //     console.log(this);
            //     layer.confirm('若导出数据量大,导出数据可能需要1~2分钟', {icon: 3, title: '提示信息'}, function (index) {
            //
            //     });
            // }
        },'/broker/getlist','','brokerid');

        //【设置弹框】
        func.setWin("人员",500,450);

        //【设置会员状态】
        form.on('switch(status)', function(obj){
            var status = this.checked ? '1' : '2';

            //发起POST请求
            var url = cUrl + "/setStatus";
            func.ajaxPost(url,{"brokerId":this.value,"status":status},function(data,res){
                console.log("请求回调");
            });

        });
    }else{

        //入职日期
        func.initDate(['entry_date|datetime'],function(value,date){
            console.log("当前选择日期:"+value);
            console.log("日期详细信息："+JSON.stringify(date));
        });

    }

});
